package day10.ZiXi;

import java.util.HashSet;

public class HashSetDemo02 {
    public static void main(String[] args) {
        ////创建HashSet集合对象
        HashSet<Student> ha = new HashSet<>();

        //创建学生对象
        Student s1 = new Student("林青霞",30);
        Student s2 = new Student("张曼玉",35);
        Student s3 = new Student("王祖贤", 33);
        Student s4 = new Student("王祖贤", 33);

        //把学生添加到集合
        ha.add(s1);
        ha.add(s2);
        ha.add(s3);
        ha.add(s4);

        //遍历集合(增强for)
        for (Student ss : ha) {
            System.out.println(ss);

        }
    }
}